<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="inc/taglibs.jsp" %>
<!DOCTYPE html>
<html lang="zh-cn">
<head>
    <%@ include file="inc/meta.jsp" %>
    <meta name="description" content="">
    <meta name="author" content="">
    <title>广告主详情</title>
    <%@ include file="inc/css.jsp" %>
</head>
<body>

<div id="posts" class="wrapper">

    <%@ include file="inc/nav.jsp" %>

    <div id="page-wrapper">
        <div class="row">
            <div class="col-lg-12">
                <c:if test="${flag == 1}">
                    <h1 class="page-header">广告主列表</h1>
                </c:if>
                <c:if test="${flag == 2}">
                    <h1 class="page-header">认证列表</h1>
                </c:if>
                <h4 style="margin-left: 10px;">——广告主详情</h4>
            </div>
        </div>

        <div class="row">
            <div class="col-lg-12">
                <div class="panel panel-default">
                    <!-- /.panel-heading -->
                    <div class="panel-body">
                        <form class="form-horizontal">

                            <!-- 未申请认证的广告主将只展示基本信息 -->
                            <c:if test="${companyUser.type == 0}">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">手机号:</label>

                                    <div class="col-sm-4" style="padding-top: 6.5px;">
                                            ${companyUser.mobile}
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">姓名:</label>

                                    <div class="col-sm-4" style="padding-top: 6.5px;">
                                            ${companyUser.nickName}
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">认证状态:</label>

                                    <div class="col-sm-4" style="padding-top: 6.5px;">
                                        未申请认证
                                    </div>
                                </div>
                            </c:if>

                            <!-- 已经申请认证的广告主将展示认证信息 -->
                            <c:if test="${companyUser.type != 0}">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">手机号:</label>

                                    <div class="col-sm-4" style="padding-top: 6.5px;">
                                            ${companyUser.mobile}
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">账户余额:</label>

                                    <div class="col-sm-4" style="padding-top: 6.5px;">
                                        ￥${companyUser.money}
                                    </div>
                                </div>

                                <div class="form-group">
                                    <label class="col-sm-2 control-label">冻结余额:</label>

                                    <div class="col-sm-4" style="padding-top: 6.5px;">
                                        ￥${companyUser.staticMoney}
                                    </div>
                                </div>

                                <c:if test="${personalAuth != null}">
                                    <!-- 个人广告主认证 -->
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">认证类型:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                            个人广告主认证
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">姓名:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                                ${personalAuth.userName}
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">个人证件:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                            <c:if test="${personalAuth.paperType == 1}">
                                                身份证（${personalAuth.paperNum}）
                                            </c:if>
                                            <c:if test="${personalAuth.paperType == 2}">
                                                护照（${personalAuth.paperNum}）
                                            </c:if>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">手持证件照片:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                            <img src="${personalAuth.userPaperUrl}" height="150px" width="150px"/>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">手机号码:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                                ${personalAuth.mobile}
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">电子邮箱:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                                ${personalAuth.email}
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">联系地址:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                                ${personalAuth.address}
                                        </div>
                                    </div>
                                </c:if>

                                <c:if test="${companyAuth != null}">
                                    <!-- 企业广告主认证 -->
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">认证类型:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                            企业广告主认证
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">企业全称:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                                ${companyAuth.companyName}
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">营业执照:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                                ${companyAuth.licenseNum}
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">执照照片:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                            <img src="${companyAuth.licenseUrl}" height="150px" width="150px"/>
                                            <img src="${companyAuth.licenseUrl2}" height="150px" width="150px"/>
                                            <img src="${companyAuth.licenseUrl3}" height="150px" width="150px"/>
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">负责人姓名:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                                ${companyAuth.userName}
                                        </div>
                                    </div>

                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">手机号码:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                                ${companyAuth.mobile}
                                        </div>
                                    </div>
                                </c:if>
                            </c:if>

                            <c:if test="${flag == 2}">
                                <div class="form-group">
                                    <label class="col-sm-2 control-label">审核状态:</label>

                                    <div class="col-sm-4" style="padding-top: 6.5px;">
                                        <span id="showSpan">
                                            <c:if test="${companyUser.checkStatus == 0}">待审核</c:if>
                                            <c:if test="${companyUser.checkStatus == 1}">审核通过</c:if>
                                            <c:if test="${companyUser.checkStatus == 2}">审核失败</c:if>
                                        </span>
                                    </div>
                                </div>

                                <c:if test="${companyUser.checkStatus == 2}">
                                    <div class="form-group">
                                        <label class="col-sm-2 control-label">审核失败原因:</label>

                                        <div class="col-sm-4" style="padding-top: 6.5px;">
                                                ${companyUser.checkFailReason}
                                        </div>
                                    </div>
                                </c:if>
                            </c:if>

                            <div class="form-group" style="display: none" id="hiddenDiv">
                                <label class="col-sm-2 control-label">审核失败原因:</label>

                                <div class="col-sm-4" style="padding-top: 6.5px;">
                                    <span id="tempSpan"></span>
                                </div>
                            </div>

                            <div class="form-group">
                                <div class="col-sm-12" style="text-align: center">
                                    <c:if test="${null == flag || flag == 1}">
                                        <a href="backend/companyUser/index" class="btn btn-primary" role="button">返回</a>
                                    </c:if>
                                    <c:if test="${flag == 2}">
                                        <c:if test="${companyUser.checkStatus == 0}">
                                            <a href="javascript:void(0)" class="btn btn-success" id="checkButtonToSuccess" onclick="_companyUserInfo.fn.changeCheckStatus(${companyUser.id},1)" role="button">审核通过</a>
                                            <a href="javascript:void(0)" class="btn btn-danger" id="checkButtonToFail" onclick="_companyUserInfo.fn.changeCheckStatus(${companyUser.id},2)" role="button">审核失败</a>
                                        </c:if>
                                        <a href="backend/companyUser/indexToCheck" class="btn btn-primary" role="button">返回</a>
                                    </c:if>
                                </div>
                            </div>
                        </form>
                    </div>
                    <!-- /.panel-body -->

                </div>
            </div>
        </div>

    </div>
    <!-- /#page-wrapper -->

</div>
<!-- /#wrapper -->

<div class="modal fade" id="delModal" tabindex="-1" role="dialog" aria-labelledby="pwdModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
                <h4 class="modal-title">审核失败原因</h4>
            </div>
            <div class="modal-body">
                <input type="hidden" id="companyUserId" value="${companyUser.id}"/>
                <textarea id="failReasonContent" cols="40" rows="6" class="form-control" style="resize: none;"></textarea>
            </div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" onclick="_companyUserInfo.fn.changeCheckStatusToFail()" class="btn btn-primary">确定</button>
            </div>
        </div>
        <!-- /.modal-content -->
    </div>
    <!-- /.modal-dialog -->
</div>

<%@ include file="inc/footer.jsp" %>

</body>

<script type="text/javascript">
    var _companyUserInfo = {
        v: {
            id: "_companyUserInfo"
        },
        fn: {
            changeCheckStatus: function (id, status) {
                if (status == 1) {
                    // 审核通过
                    $leoman.ajax("backend/companyUser/changeCheckStatus", {
                        "companyUserId": id,
                        "status": status
                    }, function (result) {
                        if (result == 1) {
                            $leoman.notify("操作成功", "success");
                            _companyUserInfo.fn.endThings(1, '');
                        } else {
                            $leoman.notify("操作失败", "error");
                        }
                    });
                } else {
                    // 审核失败
                    $("#delModal").modal("show");
                }
            },
            changeCheckStatusToFail: function () {
                var failReasonContent = $('#failReasonContent').val();

                if (null == failReasonContent || failReasonContent == '') {
                    $leoman.notify("审核失败原因不能为空", "error");
                    return;
                } else {
                    $leoman.ajax("backend/companyUser/changeCheckStatus", {
                        companyUserId: $('#companyUserId').val(),
                        status: 2,
                        failReasonContent: failReasonContent
                    }, function (result) {
                        if (result == 1) {
                            $("#delModal").modal("hide");
                            _companyUserInfo.fn.endThings(2, failReasonContent);
                            $leoman.notify("操作成功", "success");
                        } else {
                            $leoman.notify("操作失败", "error");
                        }
                    });
                }
            },
            endThings: function (status, content) {
                $('#checkButtonToSuccess').css("display", "none");
                $('#checkButtonToFail').css("display", "none");
                if (status == 2) {
                    $('#tempSpan').html(content);
                    $('#showSpan').html('审核失败');
                    $('#hiddenDiv').css('display', '');
                } else {
                    $('#showSpan').html('审核通过');
                }
            }
        }
    }

    $(document).ready(function () {
        _companyUserInfo.fn.init();
    });

</script>

</html>